package fl.ass.service.transform;

import cn.cmm.base.framework.utils.CollectionUtils;
import fl.ass.facade.dto.AssTrailCarMDTO;
import fl.ass.service.po.AssTrailCarM;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

 /**
 * @Description: 拖车信息主表 转换器
 * @Description: 服务层与展现层转换类
 * @Description: 所有的PO只能在持久成和服务层使用
 * @Description: 所有的DTO只能在展现层和服务层使用
 * @Description: 在服务层中向下是DTO转PO,向上是PO转DTO
 */
public class AssTrailCarMTransform {


	/**
	 * PO 转  DTO
	 * @param po AssTrailCarM
	 * @return AssTrailCarMDTO
	 */
	public static AssTrailCarMDTO toDTO(AssTrailCarM po) {
		AssTrailCarMDTO  dto = null;
		if (po != null) { 
			dto = new AssTrailCarMDTO();
            BeanUtils.copyProperties(po, dto);
		}
		return dto;
	}

	/**
	 * DTO 转  PO
	 * @param dto AssTrailCarMDTO
	 * @return AssTrailCarM
	 */
	public static AssTrailCarM toPO(AssTrailCarMDTO dto) {
		AssTrailCarM po = null;
		if (dto != null) {
			po = new AssTrailCarM();
            BeanUtils.copyProperties(dto, po);
		}
		return po;
	}
	
	/**
	 * PO集合 转 DTO集合
	 * @param list List<AssTrailCarM>
	 * @return List<AssTrailCarMDTO>
	 */
	public static List<AssTrailCarMDTO> toDTOList(List<AssTrailCarM> list) {
		List<AssTrailCarMDTO>  voList = new ArrayList<AssTrailCarMDTO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (AssTrailCarM po : list) {
				voList.add(toDTO(po));
			}
		}
		return voList;
	}
}
